<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * Timemap.js Copyright 2010 Nick Rabinowitz.
<span class='line'>  3</span>  * Licensed under the MIT License (see LICENSE.txt)
<span class='line'>  4</span>  */</span><span class="WHIT">
<span class='line'>  5</span> </span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @fileOverview
<span class='line'>  8</span>  * GeoRSS Loader
<span class='line'>  9</span>  *
<span class='line'> 10</span>  * @author Nick Rabinowitz (www.nickrabinowitz.com)
<span class='line'> 11</span>  */</span><span class="WHIT">
<span class='line'> 12</span> 
<span class='line'> 13</span> </span><span class="COMM">/*globals TimeMap, TimeMapDataset */</span><span class="WHIT">
<span class='line'> 14</span> 
<span class='line'> 15</span> </span><span class="COMM">/**
<span class='line'> 16</span>  * @class
<span class='line'> 17</span>  * GeoRSS loader: Load GeoRSS feeds.
<span class='line'> 18</span>  *
<span class='line'> 19</span>  * &lt;p> Parsing is complicated by the 
<span class='line'> 20</span>  * diversity of GeoRSS formats; this parser handles:&lt;/p>
<span class='line'> 21</span>  * &lt;ul>
<span class='line'> 22</span>  *  &lt;li>RSS feeds&lt;/li>
<span class='line'> 23</span>  *  &lt;li>Atom feeds&lt;/li>
<span class='line'> 24</span>  * &lt;/ul>
<span class='line'> 25</span>  * &lt;p>and looks for geographic information in the following formats:&lt;/p>
<span class='line'> 26</span>  * &lt;ul>
<span class='line'> 27</span>  *  &lt;li>GeoRSS-Simple&lt;/li>
<span class='line'> 28</span>  *  &lt;li>GML &lt;/li>
<span class='line'> 29</span>  *  &lt;li>W3C Geo&lt;/li>
<span class='line'> 30</span>  * &lt;/ul>
<span class='line'> 31</span>  * &lt;p>At the moment, this only supports points, polygons, polylines; boxes
<span class='line'> 32</span>  * may be added at some later point.&lt;/p>
<span class='line'> 33</span>  *
<span class='line'> 34</span>  * @augments TimeMap.loaders.xml
<span class='line'> 35</span>  * @requires loaders/xml.js
<span class='line'> 36</span>  * @requires param.js
<span class='line'> 37</span>  * @borrows TimeMap.loaders.georss.parse as #parse
<span class='line'> 38</span>  *
<span class='line'> 39</span>  * @example
<span class='line'> 40</span> TimeMap.init({
<span class='line'> 41</span>     datasets: [
<span class='line'> 42</span>         {
<span class='line'> 43</span>             title: "GeoRSS Dataset",
<span class='line'> 44</span>             type: "georss", // Data to be loaded in GeoRSS
<span class='line'> 45</span>             options: {
<span class='line'> 46</span>                 url: "mydata.rss" // GeoRSS file to load - must be a local URL
<span class='line'> 47</span>             }
<span class='line'> 48</span>         }
<span class='line'> 49</span>     ],
<span class='line'> 50</span>     // etc...
<span class='line'> 51</span> });
<span class='line'> 52</span>  * @see &lt;a href="../../examples/earthquake_georss.html">GeoRSS Example&lt;/a>
<span class='line'> 53</span>  *
<span class='line'> 54</span>  * @param {Object} options          All options for the loader:
<span class='line'> 55</span>  * @param {String} options.url          URL of GeoRSS file to load (NB: must be local address)
<span class='line'> 56</span>  * @param {mixed} [options[...]]        Other options (see {@link TimeMap.loaders.xml})
<span class='line'> 57</span>  */</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="NAME">TimeMap.loaders.georss</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.xml</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT">    </span><span class="NAME">loader.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.loaders.georss.parse</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">loader</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="COMM">/**
<span class='line'> 65</span>  * Static function to parse GeoRSS
<span class='line'> 66</span>  *
<span class='line'> 67</span>  * @param {XML} node      GeoRSS node to be parsed
<span class='line'> 68</span>  * @return {TimeMapItem[]}  Array of TimeMapItems
<span class='line'> 69</span>  */</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="NAME">TimeMap.loaders.georss.parse</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">items</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">placemarks</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">nList</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT">    </span><span class="COMM">// get TimeMap utilty functions</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT">    </span><span class="COMM">// assigning to variables should compress better</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">util</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TimeMap.util</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT">        </span><span class="NAME">getTagValue</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.getTagValue</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT">        </span><span class="NAME">getNodeList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.getNodeList</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT">        </span><span class="NAME">makePoint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.makePoint</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT">        </span><span class="NAME">makePoly</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.makePoly</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">        </span><span class="NAME">formatDate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.formatDate</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">        </span><span class="NAME">nsMap</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">util.nsMap</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">    </span><span class="COMM">// define namespaces</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT">    </span><span class="NAME">nsMap.georss</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://www.georss.org/georss'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT">    </span><span class="NAME">nsMap.gml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://www.opengis.net/gml'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT">    </span><span class="NAME">nsMap.geo</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://www.w3.org/2003/01/geo/wgs84_pos#'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT">    </span><span class="NAME">nsMap.kml</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'http://www.opengis.net/kml/2.2'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT">    </span><span class="COMM">// determine whether this is an Atom feed or an RSS feed</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">feedType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">node.firstChild.tagName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'rss'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">'rss'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'atom'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">    </span><span class="COMM">// look for placemarks</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">tName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">feedType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'rss'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"item"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"entry"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">    </span><span class="NAME">placemarks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">node</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">placemarks.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">        </span><span class="NAME">pm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemarks</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">        </span><span class="NAME">data</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">        </span><span class="COMM">// get title & description</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">        </span><span class="NAME">data.title</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"title"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">        </span><span class="NAME">tName</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">feedType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'rss'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"description"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"summary"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">        </span><span class="NAME">data.options.description</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">tName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">        </span><span class="COMM">// get time information, allowing KML-namespaced time elements</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">        </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"TimeStamp"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"kml"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">            </span><span class="NAME">data.start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"when"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"kml"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">        </span><span class="COMM">// look for timespan</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data.start</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">            </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"TimeSpan"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"kml"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">                </span><span class="NAME">data.start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"begin"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"kml"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">                </span><span class="NAME">data.end</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"end"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"kml"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">                    </span><span class="COMM">// unbounded spans end at the present time</span><span class="WHIT">
<span class='line'>114</span> </span><span class="WHIT">                    </span><span class="NAME">formatDate</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>115</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>116</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>117</span> </span><span class="WHIT">        </span><span class="COMM">// otherwise, use pubDate/updated elements</span><span class="WHIT">
<span class='line'>118</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">data.start</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">feedType</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'rss'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT">                </span><span class="COMM">// RSS needs date conversion</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">d</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">Date.parse</span><span class="PUNC">(</span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"pubDate"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">                </span><span class="COMM">// reformat</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">                </span><span class="NAME">data.start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">formatDate</span><span class="PUNC">(</span><span class="NAME">d</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">                </span><span class="COMM">// atom uses ISO 8601</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">                </span><span class="NAME">data.start</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"updated"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT">        </span><span class="COMM">// find placemark - single geometry only for the moment</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">done</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT">        </span><span class="NAME">PLACEMARK</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">while</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">done</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">coords</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">geom</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT">            </span><span class="COMM">// look for point, GeoRSS-Simple</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT">            </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"point"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'georss'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">                </span><span class="NAME">data.point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoint</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">                </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">            </span><span class="COMM">// look for point, GML</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT">            </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Point"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">                </span><span class="COMM">// GML &lt;pos></span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT">                </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"pos"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT">                </span><span class="COMM">// GML &lt;coordinates></span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT">                    </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"coordinates"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">                    </span><span class="NAME">data.point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoint</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">                    </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>153</span> </span><span class="WHIT">            </span><span class="COMM">// look for point, W3C Geo</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"lat"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'geo'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">                </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">                    </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"lat"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'geo'</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">                    </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"long"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'geo'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">                </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">                </span><span class="NAME">data.point</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoint</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>160</span> </span><span class="WHIT">                </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>161</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">            </span><span class="COMM">// look for polyline, GeoRSS-Simple</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">            </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"line"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'georss'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">                </span><span class="NAME">data.polyline</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoly</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">                </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">            </span><span class="COMM">// look for polygon, GeoRSS-Simple</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">            </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"polygon"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'georss'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>171</span> </span><span class="WHIT">                </span><span class="NAME">data.polygon</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoly</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="WHIT">
<span class='line'>172</span> </span><span class="WHIT">                </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>173</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>174</span> </span><span class="WHIT">            </span><span class="COMM">// look for polyline, GML</span><span class="WHIT">
<span class='line'>175</span> </span><span class="WHIT">            </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"LineString"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>177</span> </span><span class="WHIT">                </span><span class="NAME">geom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"polyline"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">                </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getNodeList</span><span class="PUNC">(</span><span class="NAME">pm</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"Polygon"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">                    </span><span class="NAME">geom</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"polygon"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>184</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">nList.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>185</span> </span><span class="WHIT">                </span><span class="COMM">// GML &lt;posList></span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">                </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"posList"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> </span><span class="WHIT">                </span><span class="COMM">// GML &lt;coordinates></span><span class="WHIT">
<span class='line'>188</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>189</span> </span><span class="WHIT">                    </span><span class="NAME">coords</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">getTagValue</span><span class="PUNC">(</span><span class="NAME">nList</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">"coordinates"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'gml'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>190</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>191</span> </span><span class="WHIT">                </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>192</span> </span><span class="WHIT">                    </span><span class="NAME">data</span><span class="PUNC">[</span><span class="NAME">geom</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">makePoly</span><span class="PUNC">(</span><span class="NAME">coords</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>193</span> </span><span class="WHIT">                    </span><span class="KEYW">break</span><span class="WHIT"> </span><span class="NAME">PLACEMARK</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">                </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT">            </span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT">            </span><span class="COMM">// XXX: deal with boxes</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">            
<span class='line'>199</span>             </span><span class="NAME">done</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span> </span><span class="WHIT">        </span><span class="COMM">// look for any extra tags specified</span><span class="WHIT">
<span class='line'>202</span> </span><span class="WHIT">        </span><span class="NAME">this.parseExtra</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">        </span><span class="NAME">items.push</span><span class="PUNC">(</span><span class="NAME">data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT">    </span><span class="COMM">// clean up</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT">    </span><span class="NAME">node</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">placemarks</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">pm</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">nList</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">items</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>210</span> </span></pre></body></html>